using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MimeCloud.AssetManagement.Business.Interface;
using MimeCloud.AssetManagement.Editor.AssetCreation.Repository;
using MimeCloud.AssetManagement.ProviderServices;
using MimeCloud.AssetManagement.Business;

namespace MimeCloud.AssetManagement.Editor.AssetCreation
{
    public static class LocallyStoredAssetContent
    {
        public enum LocalStoreType
        {
            Memory,
            FileSystem
        }

        public static IAssetContent Create (LocalStoreType storeType)
        {
            var result = AssetManagerConfig.GetAssetWriterProvider().GetBlankAssetContent();
            result.ID = Int32.MinValue;
            result.CreationDate = DateTime.Now;
            result.CreatorID = result.LatestEditorID = Environment.UserName;
            result.Language = AppCommon.Current.DefaultLanguage;
            result.LanguageID = result.Language.ID;
            result.AssetContentRepositoryList.Add(CreateRepository(storeType));
            return result;
        }



        private static IRepository CreateRepository(LocalStoreType storeType)
        {
            switch (storeType)
            {
                case LocalStoreType.Memory:
                    return new MemorySingleAssetRepository();
                    break;
                case LocalStoreType.FileSystem:
                    return new LocalFileStoreSingleAssetRepository();
                    break;
                default:
                    throw new ArgumentException("No storetype selected");
            }
        }


    }
}
